package com.rz.htk.config.jobhandler;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.rz.htk.order.service.IOrderService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@JobHandler(value = "daRongTempHandler")
@Component
public class DaRongTempHandler extends IJobHandler {
    private Logger logger = LoggerFactory.getLogger("DaRongTempHandler");

    @NacosValue(value = "${enableScheduled}", autoRefreshed = true)
    private boolean enableScheduled;
    @Resource
    private IOrderService IOrderService;

    @Override
    public ReturnT<String> execute(String s) throws Exception {
        if(enableScheduled){
            try {
                XxlJobLogger.log("开始获取大荣面单信息");
                IOrderService.rightCenteralPlace();
                XxlJobLogger.log("解析中心别完成");
            }catch (Exception e){
                logger.info("推送给大荣获取面单出错 {}",e.getMessage());
                XxlJobLogger.log(e.getMessage());
            }
        }
        return SUCCESS;
    }
}
